The present invention relates to a test and debug support method for a logical language, and in particular to an operation range display method for a program suitable to test and debug based upon declarative program understanding.
A program understanding method for debugging a logical language is discussed in a paper entitled "Understanding the Control Flow of PROLOG Programs" written by L. Byrd, Research Paper 151, Dept. of Artifical Intelligence, Univ. of Edinburgh (1980). In this paper, an operation grasp model for each procedure taken as a unit is proposed, and the necessity of an operation grasp model for each clause taken as a unit is implied. The operation grasp model for each clause taken as a unit corresponding to this implication is described in Prolog-KABA Reference Manual (1984) published by Iwasaki Electronics Corporation in Japan, for example. Further, operation grasp models (referred to as "clause models") for each clause taken as a unit, for each head term of a clause taken as a unit, and for each body term of a clause taken as a unit are proposed in a paper entitled "Function and Effect of Logical Basic Processing system LONLI" presented by Hirose et al. at the 29th National Conference of the Information Processing Society of Japan (1984).
In any of these papers, however, the problem of the display method of the operation mode on those operation grasp models is not recognized.
As for the display method of the operation mode, a proposal relating to the visual display of the operation process of a logical language is provide in a paper entitled "Diagrammatical Operation Display Method of Prolog" written by Goto, document 27-6, Working Group of Symbol Manipulation, Information Processing Society of Japan (1984). Also, a proposal relating to the display method of the operation grasp model for each clause taken as a unit is made by Numao et al. in a paper entitled "PROEDIT, a screen oriented prolog programming environment", proceedings of the logic programming conference '85 in Japan (1985).
In any of the above described papers, however, support for declarative program undestanding of the program described with a logical language is not considered.
In testing and debugging a program, it is necessary to understand whether the program operates as intended or not. For supporting this understanding, it is desirable that the information supplied by a language processing system matches the program understanding method of the programmer.
As methods for understanding the operation of the program in case of a logical language, there are two methods, i.e., procedural understanding method and declarative understanding method. It can be said that the procedural understanding method provides more minute operation understanding than the declarative understanding. However, the programmer does not always produce a program using only this minute understanding method.
For example, an example of programming using the logical language PROLOG as shown in FIG. 1 is assumed. A PROLOG program comprises one or more procedures, and each procedure comprises one or more clauses. A clause comprises a sequence of one or more terms and the first term of the sequence is called a head term and others are called body terms. The program shown in FIG. 1 comprises one procedure "d-letter" and it has three clauses as designated by numerals 1, 2 and 3. Clauses 1 and 2 are fact clauses. Clause 3 is a rule clause comprising one head term 3A and one body term 3B. A program d-letter (X) determines whether a part of the list includes two consecutive identical elements or two alternate identical elements. This program is more easily understood by using the declarative understanding method described below. A number of programmers produce programs on the basis of this understanding method.
(Clause 1) . . . If the argument X is a list, and the first element in the list is the same as the seoond element, d-letter (X) holds true. PA0 (Clause 2) . . . If the argument X is a list, and the first element in the list is the same as the third elements, d-letter (X) holds true. PA0 (Clause 3) . . . If the argument X is a list, and d-letter (L) holds true on and after the second element of the list, d-letter (X) holds true.
It is assumed that a call
?--d--letter ([a, b, c, d]).
is issued to the above described program. In the prior art, the program operation attendant upon this call is represented by the display of the operation path. FIG. 2 shows an example of display of the operation path when the "clause" model is used. Arrows in FIG. 2 faithfully show the processing procedure of the processing system of the logical language prolog.
When the above program call is issued, clause 1 in the d-letter procedure is executed which results in an unsucce body term of clause 3 is executed, and d-letter procedure is called recursively. The sequence of the above-explained operations are indicated by the arrow passing through the box-shaped figures designated 8, 10, 12 and 14. After the second call of the d-letter procedure, clauses 1 and 2 of the procedure are executed and the execution of clause 2 results in a successful end. These operations are indicated by the arrow passing through the box-shaped figure designated by 16 and 18. That is to say, the arrows are displays corresponding to the procedural understanding method. It is difficult to make these displays correspond to understanding of the above described (clause 1), (clause 2) and (clause 3), i.e., the declarative understanding method. Because the displayed entire operation path extending from the program start to the program end must be tracked for reading out of the display of FIG. 2 the necessary information representing which clause has been used.